Micron Document
<!DOCTYPE html>
<html class="client-nojs vector-feature-night-mode-disabled vector-feature-language-in-header-enabled vector-feature-language-in-main-page-header-disabled vector-feature-page-tools-pinned-disabled vector-feature-toc-pinned-clientpref-1 vector-feature-main-menu-pinned-disabled vector-feature-limited-width-clientpref-1 vector-feature-limited-width-content-enabled vector-feature-custom-font-size-clientpref-1 vector-feature-appearance-pinned-clientpref-1 vector-sticky-header-enabled" lang="en" dir="ltr"><head>
<meta charset="UTF-8">
<title>Java Database Connectivity</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="canonical" href="https://en.wikipedia.org/wiki/Java_Database_Connectivity"> <link href="./mw/ext.cite.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/ext.pygments.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.icons.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.search.codex.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/skins.vector.styles.css" rel="stylesheet" type="text/css">
<link href="./mw/user.styles.css" rel="stylesheet" type="text/css">
<meta name="ResourceLoaderDynamicStyles" content="">
<link rel="stylesheet" type="text/css" href="./mw/site.styles.css">
<link rel="stylesheet" type="text/css" href="./mw/noscript.css">
<link rel="stylesheet" type="text/css" href="./footer.css">
<link rel="stylesheet" type="text/css" href="./vector-2022.css">
</head>
<body class="skin--responsive skin-vector skin-vector-search-vue mediawiki ltr sitedir-ltr mw-hide-empty-elt ns-0 ns-subject page-Java_Database_Connectivity rootpage-Java_Database_Connectivity skin-vector-2022 action-view">
<div class="mw-page-container">
<div class="mw-page-container-inner">
<div class="mw-content-container">
<main id="content" class="mw-body">
<header class="mw-body-header vector-page-titlebar">
<h1 id="firstHeading" class="firstHeading mw-first-heading">
<span id="openzim-page-title" class="mw-page-title-main"><span class="mw-page-title-main">Java Database Connectivity</span></span>
</h1>
</header>
<a id="top"></a>
<div id="bodyContent" class="vector-body ve-init-mw-desktopArticleTarget-targetContainer" aria-labelledby="firstHeading" data-mw-ve-target-container="">
<div id="mw-content-text" class="mw-body-content mw-content-ltr" lang="en" dir="ltr"><div class="mw-content-ltr mw-parser-output" lang="en" dir="ltr">
<p><b>Java Database Connectivity</b> (<b>JDBC</b>) is an <a href="Application_programming_interface" class="mw-redirect" title="Application programming interface">application programming interface</a> (API) for the <a href="Java_(programming_language)" title="Java (programming language)">Java</a> programming language which defines how a client may access a <a href="Database" title="Database">database</a>. It is a Java-based data access technology used for Java database connectivity. It is part of the <a href="Java_Standard_Edition" class="mw-redirect" title="Java Standard Edition">Java Standard Edition</a> platform, from <a href="Oracle_Corporation" title="Oracle Corporation">Oracle Corporation</a>. It provides methods to query and update data in a database, and is oriented toward <a href="Relational_database" title="Relational database">relational databases</a>. A JDBC-to-<a href="ODBC" class="mw-redirect" title="ODBC">ODBC</a> bridge enables connections to any ODBC-accessible data source in the <a href="Java_virtual_machine" title="Java virtual machine">Java virtual machine</a> (JVM) host environment.<style data-mw-deduplicate="TemplateStyles:r1295905060">
/* start https://en.wikipedia.org/ */


.mw-parser-output .infobox-subbox{padding:0;border:none;margin:-3px;width:auto;min-width:100%;font-size:100%;clear:none;float:none;background-color:transparent}.mw-parser-output .infobox-3cols-child{margin:auto}.mw-parser-output .infobox .navbar{font-size:100%}@media screen{html.skin-theme-clientpref-night .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .infobox-full-data:not(.notheme)>div:not(.notheme)[style]{background:#1f1f23!important;color:#f8f9fa}}@media(min-width:640px){body.skin--responsive .mw-parser-output .infobox-table{display:table!important}body.skin--responsive .mw-parser-output .infobox-table>caption{display:table-caption!important}body.skin--responsive .mw-parser-output .infobox-table>tbody{display:table-row-group}body.skin--responsive .mw-parser-output .infobox-table th,body.skin--responsive .mw-parser-output .infobox-table td{padding-left:inherit;padding-right:inherit}}


/* end https://en.wikipedia.org/ */
</style></p><table class="infobox vevent"><tbody><tr><th colspan="2" class="infobox-above summary">JDBC</th></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Programmer" title="Programmer">Developer(s)</a></th><td class="infobox-data">Oracle Corporation</td></tr><tr style="display: none;"><td colspan="2" class="infobox-full-data"></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Software_release_life_cycle" title="Software release life cycle">Stable release</a></th><td class="infobox-data"><div style="margin:0px;">JDBC 4.3
/ September&nbsp;21,&nbsp;2017<span style="display: none;">&nbsp;(<span class="bday dtstart published updated itvstart">2017-09-21</span>)</span></div></td></tr><tr style="display:none"><td colspan="2">
</td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Operating_system" title="Operating system">Operating system</a></th><td class="infobox-data"><a href="Cross-platform" class="mw-redirect" title="Cross-platform">Cross-platform</a></td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;"><a href="Software_categories#Categorization_approaches" title="Software categories">Type</a></th><td class="infobox-data">Data access API</td></tr><tr><th scope="row" class="infobox-label" style="white-space: nowrap;">Website</th><td class="infobox-data"><a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc">JDBC API Guide</a></td></tr></tbody></table>
<meta property="mw:PageProp/toc">
<div class="mw-heading mw-heading2"><h2 id="History_and_implementation">History and implementation</h2></div>
<p><a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a> released JDBC as part of <a href="Java_Development_Kit" title="Java Development Kit">Java Development Kit</a> (JDK) 1.1 on February 19, 1997.<sup id="cite_ref-JDK_1.1_release_1-0" class="reference"><a href="#cite_note-JDK_1.1_release-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
Since then it has been part of the <a href="Java_Platform%2C_Standard_Edition" title="Java Platform, Standard Edition">Java Platform, Standard Edition</a> (Java SE).
</p><p>The JDBC classes are contained in the <a href="Java_package" title="Java package">Java package</a> <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/package-summary.html">java.sql</a></code> and <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/javax/sql/package-summary.html">javax.sql</a></code>, as well as a few other classes elsewhere. Everything involved in JDBC is exported through <a href="Java_Platform_Module_System" title="Java Platform Module System">module</a> <code>java.sql</code>.
</p><p>Starting with version 3.1, JDBC has been developed under the <a href="Java_Community_Process" title="Java Community Process">Java Community Process</a>. JSR 54 specifies JDBC 3.0 (included in J2SE 1.4), JSR 114 specifies the JDBC Rowset additions, and JSR 221 is the specification of JDBC 4.0 (included in Java SE 6).<sup id="cite_ref-2" class="reference"><a href="#cite_note-2"><span class="cite-bracket">[</span>2<span class="cite-bracket">]</span></a></sup>
</p><p>JDBC 4.1, is specified by a maintenance release 1 of JSR 221<sup id="cite_ref-3" class="reference"><a href="#cite_note-3"><span class="cite-bracket">[</span>3<span class="cite-bracket">]</span></a></sup> and is included in Java SE 7.<sup id="cite_ref-4" class="reference"><a href="#cite_note-4"><span class="cite-bracket">[</span>4<span class="cite-bracket">]</span></a></sup>
</p><p>JDBC 4.2, is specified by a maintenance release 2 of JSR 221<sup id="cite_ref-5" class="reference"><a href="#cite_note-5"><span class="cite-bracket">[</span>5<span class="cite-bracket">]</span></a></sup> and is included in Java SE 8.<sup id="cite_ref-6" class="reference"><a href="#cite_note-6"><span class="cite-bracket">[</span>6<span class="cite-bracket">]</span></a></sup>
</p><p>The latest version, JDBC 4.3, is specified by a maintenance release 3 of JSR 221<sup id="cite_ref-7" class="reference"><a href="#cite_note-7"><span class="cite-bracket">[</span>7<span class="cite-bracket">]</span></a></sup> and is included in Java SE 9.<sup id="cite_ref-8" class="reference"><a href="#cite_note-8"><span class="cite-bracket">[</span>8<span class="cite-bracket">]</span></a></sup>
</p>
<table class="wikitable">
<caption>JDBC versions
</caption>
<tbody><tr>
<th>JDBC version</th>
<th>Java version</th>
<th>Release Type</th>
<th>Release date
</th></tr>
<tr>
<td>1.1</td>
<td>JDK 1.1</td>
<td>Main</td>
<td>1997-02-19.<sup id="cite_ref-JDK_1.1_release_1-1" class="reference"><a href="#cite_note-JDK_1.1_release-1"><span class="cite-bracket">[</span>1<span class="cite-bracket">]</span></a></sup>
</td></tr>
<tr>
<td><a rel="nofollow" class="external text" href="https://www.jcp.org/en/jsr/detail?id=54">3.0</a></td>
<td>J2SE 1.4</td>
<td>Main</td>
<td>2002-05-09
</td></tr>
<tr>
<td><a rel="nofollow" class="external text" href="https://www.jcp.org/en/jsr/detail?id=221">4.0</a></td>
<td>Java SE 6</td>
<td>Main</td>
<td>2006-12-11
</td></tr>
<tr>
<td><a rel="nofollow" class="external text" href="https://www.jcp.org/en/jsr/detail?id=221">4.1</a></td>
<td>Java SE 7</td>
<td>Maintenance</td>
<td>2011-10-13
</td></tr>
<tr>
<td><a rel="nofollow" class="external text" href="https://www.jcp.org/en/jsr/detail?id=221">4.2</a></td>
<td>Java SE 8</td>
<td>Maintenance</td>
<td>2014-03-04
</td></tr>
<tr>
<td><a rel="nofollow" class="external text" href="https://www.jcp.org/en/jsr/detail?id=221">4.3</a></td>
<td>Java SE 9</td>
<td>Maintenance</td>
<td>2017-09-21
</td></tr></tbody></table>
<div class="mw-heading mw-heading2"><h2 id="Functionality">Functionality</h2></div>
<table class="wikitable floatright">
<caption>Host database types which Java can convert to with a function
</caption>
<tbody><tr>
<th>Oracle Datatype
</th>
<th><code>setXXX()</code> Methods
</th></tr>
<tr>
<td>CHAR
</td>
<td><code>setString()</code>
</td></tr>
<tr>
<td>VARCHAR2
</td>
<td><code>setString()</code>
</td></tr>
<tr>
<td rowspan="8">NUMBER
</td>
<td><code>setBigDecimal()</code>
</td></tr>
<tr>
<td><code>setBoolean()</code>
</td></tr>
<tr>
<td><code>setByte()</code>
</td></tr>
<tr>
<td><code>setShort()</code>
</td></tr>
<tr>
<td><code>setInt()</code>
</td></tr>
<tr>
<td><code>setLong()</code>
</td></tr>
<tr>
<td><code>setFloat()</code>
</td></tr>
<tr>
<td><code>setDouble()</code>
</td></tr>
<tr>
<td>INTEGER
</td>
<td><code>setInt()</code>
</td></tr>
<tr>
<td>FLOAT
</td>
<td><code>setDouble()</code>
</td></tr>
<tr>
<td>CLOB
</td>
<td><code>setClob()</code>
</td></tr>
<tr>
<td>BLOB
</td>
<td><code>setBlob()</code>
</td></tr>
<tr>
<td>RAW
</td>
<td><code>setBytes()</code>
</td></tr>
<tr>
<td>LONGRAW
</td>
<td><code>setBytes()</code>
</td></tr>
<tr>
<td rowspan="3">DATE
</td>
<td><code>setDate()</code>
</td></tr>
<tr>
<td><code>setTime()</code>
</td></tr>
<tr>
<td><code>setTimestamp()</code>
</td></tr></tbody></table>
<p>Since JDBC is mostly a collection of interface definitions and specifications, it allows multiple implementations of these interfaces to exist and be used by the same application at runtime. The API provides a mechanism for dynamically loading the correct Java packages and registering them with the JDBC Driver Manager (<code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">DriverManager</code>). <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">DriverManager</code> is used as a <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Connection</span></code> <a href="Factory_(object-oriented_programming)" title="Factory (object-oriented programming)">factory</a> for creating JDBC connections.
</p><p>JDBC connections support creating and executing statements. JDBC connections support update statements such as SQL's <a href="Create_(SQL)" class="mw-redirect" title="Create (SQL)">CREATE</a>, <a href="Insert_(SQL)" title="Insert (SQL)">INSERT</a>, <a href="Update_(SQL)" title="Update (SQL)">UPDATE</a> and <a href="Delete_(SQL)" title="Delete (SQL)">DELETE</a>, or query statements such as <a href="Select_(SQL)" title="Select (SQL)">SELECT</a>. Additionally, stored procedures may be invoked through a JDBC connection. JDBC represents statements using one of the following classes:
</p>
<ul><li><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/Statement.html">Statement</a></code> – the <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Statement</span></code> is sent to the database server each and every time. In other words, the <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Statement</span></code> methods are executed using SQL statements to obtain a <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">ResultSet</code> object containing the data.<sup id="cite_ref-FOOTNOTEBai202274_9-0" class="reference"><a href="#cite_note-FOOTNOTEBai202274-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup></li>
<li><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/PreparedStatement.html">PreparedStatement</a></code> – <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">PreparedStatement</code> is a subinterface of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Statement</code> interface.<sup id="cite_ref-FOOTNOTEBai202274_9-1" class="reference"><a href="#cite_note-FOOTNOTEBai202274-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> The statement is cached and then the <a href="Query_plan" title="Query plan">execution path</a> is pre-determined on the database server, allowing it to be executed multiple times in an efficient manner.<sup id="cite_ref-FOOTNOTEBai202274_9-2" class="reference"><a href="#cite_note-FOOTNOTEBai202274-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">PreparedStatement</code> is used to execute pre-compiled SQL statements.<sup id="cite_ref-FOOTNOTEBai202274_9-3" class="reference"><a href="#cite_note-FOOTNOTEBai202274-9"><span class="cite-bracket">[</span>9<span class="cite-bracket">]</span></a></sup> Running pre-compiled statements increases statement execution efficiency and performance. The <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">PreparedStatement</code> is often used for dynamic statement where some input parameters must be passed into the target database.<sup id="cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_More_About_the_Execution_Methods_10-0" class="reference"><a href="#cite_note-FOOTNOTEBai2022122–124§4.2.3.5_More_About_the_Execution_Methods-10"><span class="cite-bracket">[</span>10<span class="cite-bracket">]</span></a></sup> The</li></ul>
<p><code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">PreparedStatement</code> allows the dynamic query to vary depending on the query parameter.<sup id="cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-0" class="reference"><a href="#cite_note-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup>
</p>
<ul><li><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/CallableStatement.html">CallableStatement</a></code> – <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">CallableStatement</code> is a subinterface of the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">Statement</code> interface.<sup id="cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-1" class="reference"><a href="#cite_note-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup> It is used for executing <a href="Stored_procedures" class="mw-redirect" title="Stored procedures">stored procedures</a> on the database.<sup id="cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-2" class="reference"><a href="#cite_note-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture-11"><span class="cite-bracket">[</span>11<span class="cite-bracket">]</span></a></sup><sup id="cite_ref-FOOTNOTEHorstmann2022§5.5.3_SQL_Escapes_12-0" class="reference"><a href="#cite_note-FOOTNOTEHorstmann2022§5.5.3_SQL_Escapes-12"><span class="cite-bracket">[</span>12<span class="cite-bracket">]</span></a></sup> Both input and output parameters must be passed into the database for stored procedures.<sup id="cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture_13-0" class="reference"><a href="#cite_note-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup></li></ul>
<p>Update statements such as INSERT, UPDATE and DELETE return an update count indicating the number of <a href="Row_(database)" title="Row (database)">rows</a> affected in the database as an integer.<sup id="cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture_13-1" class="reference"><a href="#cite_note-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture-13"><span class="cite-bracket">[</span>13<span class="cite-bracket">]</span></a></sup> These statements do not return any other information.
</p><p>Query statements return a JDBC row result set. The row result set is used to walk over the <a href="Result_set" title="Result set">result set</a>. Individual <a href="Column_(database)" title="Column (database)">columns</a> in a row are retrieved either by name or by column number. There may be any number of rows in the result set. The row result set has metadata that describes the names of the columns and their types.
</p><p>There is an extension to the basic JDBC API in the <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/javax/sql/package-summary.html">javax.sql</a></code>.
</p><p>JDBC connections are often managed via a <a href="Connection_pool" title="Connection pool">connection pool</a> rather than obtained directly from the driver.<sup id="cite_ref-FOOTNOTEBai202283§3.5.1_JDBC_DataSource_14-0" class="reference"><a href="#cite_note-FOOTNOTEBai202283§3.5.1_JDBC_DataSource-14"><span class="cite-bracket">[</span>14<span class="cite-bracket">]</span></a></sup>
</p>
<div class="mw-heading mw-heading2"><h2 id="Examples">Examples</h2></div>
<p>When a Java application needs a database connection, one of the <code>DriverManager.getConnection()</code> methods is used to create a JDBC <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Connection</span></code>. The URL used is dependent upon the particular database and JDBC driver. It will always begin with the "jdbc:" protocol, but the rest is up to the particular vendor.
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="n">Connection</span><span class="w"> </span><span class="n">conn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DriverManager</span><span class="p">.</span><span class="na">getConnection</span><span class="p">(</span>
<span class="w"> </span><span class="s">"jdbc:somejdbcvendor:other data needed by some jdbc vendor"</span><span class="p">,</span>
<span class="w"> </span><span class="s">"myLogin"</span><span class="p">,</span>
<span class="w"> </span><span class="s">"myPassword"</span><span class="p">);</span>
<span class="k">try</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="cm">/* you use the connection here */</span>
<span class="p">}</span><span class="w"> </span><span class="k">finally</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">//It's important to close the connection when you are done with it</span>
<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"> </span>
<span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">close</span><span class="p">();</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Throwable</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="cm">/* Propagate the original exception</span>
<span class="cm"> instead of this one that you want just logged */</span><span class="w"> </span>
<span class="w"> </span><span class="n">logger</span><span class="p">.</span><span class="na">warn</span><span class="p">(</span><span class="s">"Could not close JDBC Connection"</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>Starting from Java SE 7 you can use Java's <a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/tutorial/essential/exceptions/tryResourceClose.html">try-with-resources</a> statement to simplify the above code:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="w"> </span><span class="p">(</span><span class="n">Connection</span><span class="w"> </span><span class="n">conn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DriverManager</span><span class="p">.</span><span class="na">getConnection</span><span class="p">(</span>
<span class="w"> </span><span class="s">"jdbc:somejdbcvendor:other data needed by some jdbc vendor"</span><span class="p">,</span>
<span class="w"> </span><span class="s">"myLogin"</span><span class="p">,</span>
<span class="w"> </span><span class="s">"myPassword"</span><span class="p">))</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="cm">/* you use the connection here */</span>
<span class="p">}</span><span class="w"> </span><span class="c1">// the VM will take care of closing the connection</span>
</pre></div>
<p>Once a connection is established, a <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Statement</span></code> can be created.
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="w"> </span><span class="p">(</span><span class="n">Statement</span><span class="w"> </span><span class="n">stmt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">createStatement</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">stmt</span><span class="p">.</span><span class="na">executeUpdate</span><span class="p">(</span><span class="s">"INSERT INTO MyTable(name) VALUES ('my name')"</span><span class="p">);</span>
<span class="p">}</span>
</pre></div>
<p>Note that <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Connection</span></code>s, <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Statement</span></code>s, and <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">ResultSet</span></code>s often tie up <a href="Operating_system" title="Operating system">operating system</a> resources such as sockets or <a href="File_descriptor" title="File descriptor">file descriptors</a>. In the case of <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">Connection</span></code>s to remote database servers, further resources are tied up on the server, e.g. <a href="Cursor_(databases)" title="Cursor (databases)">cursors</a> for currently open <code class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><span class="n">ResultSet</span></code>s.
It is vital to <code>close()</code> any JDBC object as soon as it has played its part;
<a href="Garbage_collection_(computer_science)" title="Garbage collection (computer science)">garbage collection</a> should not be relied upon.
The above try-with-resources construct is a code pattern that obviates this.
</p><p>Data is retrieved from the database using a database query mechanism. The example below shows creating a statement and executing a query.
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="w"> </span><span class="p">(</span><span class="n">Statement</span><span class="w"> </span><span class="n">stmt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">createStatement</span><span class="p">();</span>
<span class="w"> </span><span class="n">ResultSet</span><span class="w"> </span><span class="n">rs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">stmt</span><span class="p">.</span><span class="na">executeQuery</span><span class="p">(</span><span class="s">"SELECT * FROM MyTable"</span><span class="p">)</span>
<span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">rs</span><span class="p">.</span><span class="na">next</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">numColumns</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rs</span><span class="p">.</span><span class="na">getMetaData</span><span class="p">().</span><span class="na">getColumnCount</span><span class="p">();</span>
<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">numColumns</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// Column numbers start at 1.</span>
<span class="w"> </span><span class="c1">// Also, there are many methods on the result set to return</span>
<span class="w"> </span><span class="c1">// the column as a particular type. Refer to the Sun documentation</span>
<span class="w"> </span><span class="c1">// for the list of valid conversions.</span>
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="w"> </span><span class="s">"COLUMN "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s">" = "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">rs</span><span class="p">.</span><span class="na">getObject</span><span class="p">(</span><span class="n">i</span><span class="p">));</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>The following code is an example of a <code>PreparedStatement</code> query which uses <code>conn</code> and class from the first example:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="k">try</span><span class="w"> </span><span class="p">(</span><span class="n">PreparedStatement</span><span class="w"> </span><span class="n">ps</span><span class="w"> </span><span class="o">=</span>
<span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">prepareStatement</span><span class="p">(</span><span class="s">"SELECT i.*, j.* FROM Omega i, Zappa j WHERE i.name =&nbsp;? AND j.num =&nbsp;?"</span><span class="p">)</span>
<span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// In the SQL statement being prepared, each question mark is a placeholder</span>
<span class="w"> </span><span class="c1">// that must be replaced with a value you provide through a "set" method invocation.</span>
<span class="w"> </span><span class="c1">// The following two method calls replace the two placeholders; the first is</span>
<span class="w"> </span><span class="c1">// replaced by a string value, and the second by an integer value.</span>
<span class="w"> </span><span class="n">ps</span><span class="p">.</span><span class="na">setString</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span><span class="w"> </span><span class="s">"Poor Yorick"</span><span class="p">);</span>
<span class="w"> </span><span class="n">ps</span><span class="p">.</span><span class="na">setInt</span><span class="p">(</span><span class="mi">2</span><span class="p">,</span><span class="w"> </span><span class="mi">8008</span><span class="p">);</span>

<span class="w"> </span><span class="c1">// The ResultSet, rs, conveys the result of executing the SQL statement.</span>
<span class="w"> </span><span class="c1">// Each time you call rs.next(), an internal row pointer, or cursor,</span>
<span class="w"> </span><span class="c1">// is advanced to the next row of the result. The cursor initially is</span>
<span class="w"> </span><span class="c1">// positioned before the first row.</span>
<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">(</span><span class="n">ResultSet</span><span class="w"> </span><span class="n">rs</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">ps</span><span class="p">.</span><span class="na">executeQuery</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">while</span><span class="w"> </span><span class="p">(</span><span class="n">rs</span><span class="p">.</span><span class="na">next</span><span class="p">())</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kt">int</span><span class="w"> </span><span class="n">numColumns</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">rs</span><span class="p">.</span><span class="na">getMetaData</span><span class="p">().</span><span class="na">getColumnCount</span><span class="p">();</span>
<span class="w"> </span><span class="k">for</span><span class="w"> </span><span class="p">(</span><span class="kt">int</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="mi">1</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">&lt;=</span><span class="w"> </span><span class="n">numColumns</span><span class="p">;</span><span class="w"> </span><span class="n">i</span><span class="o">++</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="c1">// Column numbers start at 1.</span>
<span class="w"> </span><span class="c1">// Also, there are many methods on the result set to return</span>
<span class="w"> </span><span class="c1">// the column as a particular type. Refer to the Sun documentation</span>
<span class="w"> </span><span class="c1">// for the list of valid conversions.</span>
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="s">"COLUMN "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">i</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="s">" = "</span><span class="w"> </span><span class="o">+</span><span class="w"> </span><span class="n">rs</span><span class="p">.</span><span class="na">getObject</span><span class="p">(</span><span class="n">i</span><span class="p">));</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// for</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// while</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="c1">// try</span>
<span class="p">}</span><span class="w"> </span><span class="c1">// try</span>
</pre></div>
<p>If a database operation fails, JDBC raises an <code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/SQLException.html">SQLException</a></code>. There is typically very little one can do to recover from such an error, apart from logging it with as much detail as possible. It is recommended that the <code class="mw-highlight mw-highlight-lang-text mw-content-ltr" style="" dir="ltr">SQLException</code> be translated into an application domain exception (an unchecked one) that eventually results in a transaction rollback and a notification to the user.
</p><p>The following code is an example of a <a href="Database_transaction" title="Database transaction">database transaction</a>:
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="kt">boolean</span><span class="w"> </span><span class="n">autoCommitDefault</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">getAutoCommit</span><span class="p">();</span>
<span class="k">try</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">setAutoCommit</span><span class="p">(</span><span class="kc">false</span><span class="p">);</span>

<span class="w"> </span><span class="cm">/* You execute statements against conn here transactionally */</span>

<span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">commit</span><span class="p">();</span>
<span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Throwable</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">rollback</span><span class="p">();</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Throwable</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">logger</span><span class="p">.</span><span class="na">warn</span><span class="p">(</span><span class="s">"Could not rollback transaction"</span><span class="p">,</span><span class="w"> </span><span class="n">e</span><span class="p">);</span><span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="k">throw</span><span class="w"> </span><span class="n">e</span><span class="p">;</span>
<span class="p">}</span><span class="w"> </span><span class="k">finally</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">setAutoCommit</span><span class="p">(</span><span class="n">autoCommitDefault</span><span class="p">);</span><span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Throwable</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span><span class="w"> </span><span class="n">logger</span><span class="p">.</span><span class="na">warn</span><span class="p">(</span><span class="s">"Could not restore AutoCommit setting"</span><span class="p">,</span><span class="n">e</span><span class="p">);</span><span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<p>For an example of a <code>CallableStatement</code> (to call stored procedures in the database), see the <a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/getstart/callablestatement.html">JDBC API Guide</a> documentation.
</p>
<div class="mw-highlight mw-highlight-lang-java mw-content-ltr" dir="ltr"><pre><span class="kn">import</span><span class="w"> </span><span class="nn">java.sql.Connection</span><span class="p">;</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">java.sql.DriverManager</span><span class="p">;</span>
<span class="kn">import</span><span class="w"> </span><span class="nn">java.sql.Statement</span><span class="p">;</span>

<span class="kd">public</span><span class="w"> </span><span class="kd">class</span> <span class="nc">Mydb1</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="kd">static</span><span class="w"> </span><span class="n">String</span><span class="w"> </span><span class="n">URL</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"jdbc:mysql://localhost/mydb"</span><span class="p">;</span>

<span class="w"> </span><span class="kd">public</span><span class="w"> </span><span class="kd">static</span><span class="w"> </span><span class="kt">void</span><span class="w"> </span><span class="nf">main</span><span class="p">(</span><span class="n">String</span><span class="o">[]</span><span class="w"> </span><span class="n">args</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="k">try</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">Class</span><span class="p">.</span><span class="na">forName</span><span class="p">(</span><span class="s">"com.mysql.jdbc.Driver"</span><span class="p">);</span>

<span class="w"> </span><span class="n">Connection</span><span class="w"> </span><span class="n">conn</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">DriverManager</span><span class="p">.</span><span class="na">getConnection</span><span class="p">(</span><span class="n">URL</span><span class="p">,</span><span class="w"> </span><span class="s">"root"</span><span class="p">,</span><span class="w"> </span><span class="s">"root"</span><span class="p">);</span>
<span class="w"> </span><span class="n">Statement</span><span class="w"> </span><span class="n">stmt</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="n">conn</span><span class="p">.</span><span class="na">createStatement</span><span class="p">();</span>
<span class="w"> </span>
<span class="w"> </span><span class="n">String</span><span class="w"> </span><span class="n">sql</span><span class="w"> </span><span class="o">=</span><span class="w"> </span><span class="s">"INSERT INTO emp1 VALUES ('pctb5361', 'kiril', 'john', 968666668)"</span><span class="p">;</span>
<span class="w"> </span><span class="n">stmt</span><span class="p">.</span><span class="na">executeUpdate</span><span class="p">(</span><span class="n">sql</span><span class="p">);</span>
<span class="w"> </span>
<span class="w"> </span><span class="n">System</span><span class="p">.</span><span class="na">out</span><span class="p">.</span><span class="na">println</span><span class="p">(</span><span class="s">"Inserted records into the table..."</span><span class="p">);</span>
<span class="w"> </span><span class="p">}</span><span class="w"> </span><span class="k">catch</span><span class="w"> </span><span class="p">(</span><span class="n">Exception</span><span class="w"> </span><span class="n">e</span><span class="p">)</span><span class="w"> </span><span class="p">{</span>
<span class="w"> </span><span class="n">e</span><span class="p">.</span><span class="na">printStackTrace</span><span class="p">();</span>
<span class="w"> </span><span class="p">}</span>
<span class="w"> </span><span class="p">}</span>
<span class="p">}</span>
</pre></div>
<div class="mw-heading mw-heading2"><h2 id="JDBC_drivers">JDBC drivers</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1236090951">
/* start https://en.wikipedia.org/ */


.mw-parser-output .hatnote{font-style:italic}.mw-parser-output div.hatnote{padding-left:1.6em;margin-bottom:0.5em}.mw-parser-output .hatnote i{font-style:normal}.mw-parser-output .hatnote+link+.hatnote{margin-top:-0.5em}@media print{body.ns-0 .mw-parser-output .hatnote{display:none!important}}


/* end https://en.wikipedia.org/ */
</style><div role="note" class="hatnote navigation-not-searchable">Main article: <a href="JDBC_driver" title="JDBC driver">JDBC driver</a></div>
<p>JDBC drivers are client-side <a href="Adapter_pattern" title="Adapter pattern">adapters</a> (installed on the client machine, not on the server) that convert requests from Java programs to a protocol that the DBMS can understand.
</p>
<div class="mw-heading mw-heading3"><h3 id="Types">Types</h3></div>
<p>Commercial and free drivers provide connectivity to most relational-database servers. These drivers fall into one of the following types:
</p>
<ul><li><a href="JDBC_driver#Type_1_Driver_-_JDBC-ODBC_bridge" title="JDBC driver">Type 1</a> that calls native code of the locally available ODBC driver. (Note: In JDBC 4.2, JDBC-ODBC bridge has been removed<sup id="cite_ref-15" class="reference"><a href="#cite_note-15"><span class="cite-bracket">[</span>15<span class="cite-bracket">]</span></a></sup>)</li>
<li><a href="JDBC_driver#Type_2_Driver_-_Native-API_Driver" title="JDBC driver">Type 2</a> that calls database vendor native library on a client side. This code then talks to database over the network.</li>
<li><a href="JDBC_driver#Type_3_Driver_-_Network-Protocol_Driver(MiddleWare_Driver)" title="JDBC driver">Type 3</a>, the pure-java driver that talks with the server-side middleware that then talks to the database.</li>
<li><a href="JDBC_driver#Type_4_Driver_-_Database-Protocol_Driver(Pure_Java_Driver)" title="JDBC driver">Type 4</a>, the pure-java driver that uses database native protocol.</li></ul>
<p>Note also a type called an internal JDBC driver - a driver embedded with <a href="Java_Runtime_Environment" class="mw-redirect" title="Java Runtime Environment">JRE</a> in Java-enabled SQL databases. It is used for <a href="Java_stored_procedure" class="mw-redirect" title="Java stored procedure">Java stored procedures</a>. This does not fit into the classification scheme above, although it would likely resemble either a type 2 or type 4 driver (depending on whether the database itself is implemented in Java or not). An example of this is the KPRB (Kernel Program Bundled) driver<sup id="cite_ref-16" class="reference"><a href="#cite_note-16"><span class="cite-bracket">[</span>16<span class="cite-bracket">]</span></a></sup>
supplied with <a href="Oracle_Database" title="Oracle Database">Oracle RDBMS</a>. "jdbc:default:connection" offers a relatively standard way of making such a connection (at least the Oracle database and <a href="Apache_Derby" title="Apache Derby">Apache Derby</a> support it). However, in the case of an internal JDBC driver, the JDBC client actually runs as part of the database being accessed, and so can access data directly rather than through network protocols.
</p>
<div class="mw-heading mw-heading3"><h3 id="Sources">Sources</h3></div>
<ul><li><a href="Oracle_Corporation" title="Oracle Corporation">Oracle</a> provides a <a rel="nofollow" class="external text" href="http://www.oracle.com/technetwork/java/index-136695.html">list of some JDBC drivers and vendors</a></li>
<li><a href="Simba_Technologies" title="Simba Technologies">Simba Technologies</a> ships an SDK for building custom JDBC Drivers for any custom/proprietary relational data source</li>
<li>CData Software ships type 4 JDBC Drivers for various applications, databases, and Web APIs.<sup id="cite_ref-17" class="reference"><a href="#cite_note-17"><span class="cite-bracket">[</span>17<span class="cite-bracket">]</span></a></sup></li>
<li>RSSBus Type 4 JDBC Drivers for applications, databases, and web services<sup id="cite_ref-18" class="reference"><a href="#cite_note-18"><span class="cite-bracket">[</span>18<span class="cite-bracket">]</span></a></sup></li>
<li>DataDirect Technologies provides a comprehensive suite of fast Type 4 JDBC drivers for all major database they advertise as Type 5<sup id="cite_ref-datadirect_19-0" class="reference"><a href="#cite_note-datadirect-19"><span class="cite-bracket">[</span>19<span class="cite-bracket">]</span></a></sup></li>
<li>IDS Software provides a Type 3 JDBC driver for concurrent access to all major databases. Supported features include resultset caching, SSL encryption, custom data source, dbShield</li>
<li>JDBaccess is a Java persistence library for <a href="MySQL" title="MySQL">MySQL</a> and <a href="Oracle_database" class="mw-redirect" title="Oracle database">Oracle</a> which defines major database access operations in an easy usable API above JDBC</li>
<li>JNetDirect provides a suite of fully Sun J2EE certified high-performance JDBC drivers.</li>
<li>JDBCR4 is a service program written by <a href="Scott_Klement" title="Scott Klement">Scott Klement</a> to allow access to JDBC from <a href="IBM_RPG" title="IBM RPG">RPG</a> on the <a href="IBM_i" title="IBM i">IBM i</a>.<sup id="cite_ref-20" class="reference"><a href="#cite_note-20"><span class="cite-bracket">[</span>20<span class="cite-bracket">]</span></a></sup></li>
<li><a href="HSQLDB" title="HSQLDB">HSQLDB</a> is a <a href="Relational_database_management_system" class="mw-redirect" title="Relational database management system">RDBMS</a> with a JDBC driver and is available under a BSD license.</li>
<li>SchemaCrawler<sup id="cite_ref-schemacrawler_21-0" class="reference"><a href="#cite_note-schemacrawler-21"><span class="cite-bracket">[</span>21<span class="cite-bracket">]</span></a></sup> is an open source API that leverages JDBC, and makes database metadata available as plain old Java objects (POJOs)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="See_also">See also</h2></div>
<ul><li><a href="GNU_Data_Access" class="mw-redirect" title="GNU Data Access">GNU Data Access</a> (GDA)</li>
<li><a href="JDBCFacade" title="JDBCFacade">JDBCFacade</a></li>
<li><a href="Open_Database_Connectivity" title="Open Database Connectivity">Open Database Connectivity</a> (ODBC)</li>
<li><a href="Object%E2%80%93relational_mapping" title="Object–relational mapping">Object–relational mapping</a> (ORM)</li></ul>
<div class="mw-heading mw-heading2"><h2 id="Citations">Citations</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1239543626">
/* start https://en.wikipedia.org/ */


.mw-parser-output .reflist{margin-bottom:0.5em;list-style-type:decimal}@media screen{.mw-parser-output .reflist{font-size:90%}}.mw-parser-output .reflist .references{font-size:100%;margin-bottom:0;list-style-type:inherit}.mw-parser-output .reflist-columns-2{column-width:30em}.mw-parser-output .reflist-columns-3{column-width:25em}.mw-parser-output .reflist-columns{margin-top:0.3em}.mw-parser-output .reflist-columns ol{margin-top:0}.mw-parser-output .reflist-columns li{page-break-inside:avoid;break-inside:avoid-column}.mw-parser-output .reflist-upper-alpha{list-style-type:upper-alpha}.mw-parser-output .reflist-upper-roman{list-style-type:upper-roman}.mw-parser-output .reflist-lower-alpha{list-style-type:lower-alpha}.mw-parser-output .reflist-lower-greek{list-style-type:lower-greek}.mw-parser-output .reflist-lower-roman{list-style-type:lower-roman}


/* end https://en.wikipedia.org/ */
</style><div class="reflist">
<div class="mw-references-wrap mw-references-columns"><ol class="references">
<li id="cite_note-JDK_1.1_release-1"><span class="mw-cite-backlink">^ <a href="#cite_ref-JDK_1.1_release_1-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-JDK_1.1_release_1-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text">
<style data-mw-deduplicate="TemplateStyles:r1238218222">
/* start https://en.wikipedia.org/ */


.mw-parser-output cite.citation{font-style:inherit;word-wrap:break-word}.mw-parser-output .citation q{quotes:"\"""\"""'""'"}.mw-parser-output .citation:target{background-color:rgba(0,127,255,0.133)}.mw-parser-output .id-lock-free.id-lock-free a{background:url("./mw/Lock-green.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-limited.id-lock-limited a,.mw-parser-output .id-lock-registration.id-lock-registration a{background:url("./mw/Lock-gray-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .id-lock-subscription.id-lock-subscription a{background:url("./mw/Lock-red-alt-2.svg")right 0.1em center/9px no-repeat}.mw-parser-output .cs1-ws-icon a{background:url("./mw/Wikisource-logo.svg")right 0.1em center/12px no-repeat}body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-free a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-limited a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-registration a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .id-lock-subscription a,body:not(.skin-timeless):not(.skin-minerva) .mw-parser-output .cs1-ws-icon a{background-size:contain;padding:0 1em 0 0}.mw-parser-output .cs1-code{color:inherit;background:inherit;border:none;padding:inherit}.mw-parser-output .cs1-hidden-error{display:none;color:var(--color-error,#d33)}.mw-parser-output .cs1-visible-error{color:var(--color-error,#d33)}.mw-parser-output .cs1-maint{display:none;color:#085;margin-left:0.3em}.mw-parser-output .cs1-kern-left{padding-left:0.2em}.mw-parser-output .cs1-kern-right{padding-right:0.2em}.mw-parser-output .citation .mw-selflink{font-weight:inherit}@media screen{.mw-parser-output .cs1-format{font-size:95%}html.skin-theme-clientpref-night .mw-parser-output .cs1-maint{color:#18911f}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .cs1-maint{color:#18911f}}


/* end https://en.wikipedia.org/ */
</style><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20080210044125/http://www.sun.com/smi/Press/sunflash/1997-02/sunflash.970219.0001.xml">"Sun Ships JDK 1.1 -- Javabeans Included"</a>. <i>www.sun.com</i>. <a href="Sun_Microsystems" title="Sun Microsystems">Sun Microsystems</a>. 1997-02-19. Archived from <a rel="nofollow" class="external text" href="http://www.sun.com/smi/Press/sunflash/1997-02/sunflash.970219.0001.xml">the original</a> on 2008-02-10<span class="reference-accessdate">. Retrieved <span class="nowrap">2010-02-15</span></span>. <q>February 19, 1997 - The JDK 1.1 [...] is now available [...]. This release of the JDK includes: [...] Robust new features including JDBC for database connectivity</q></cite></span>
</li>
<li id="cite_note-2"><span class="mw-cite-backlink"><b><a href="#cite_ref-2">^</a></b></span> <span class="reference-text"><a rel="nofollow" class="external text" href="http://java.sun.com/products/jdbc/download.html#corespec40">JDBC API Specification Version: 4.0</a>.</span>
</li>
<li id="cite_note-3"><span class="mw-cite-backlink"><b><a href="#cite_ref-3">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://jcp.org/aboutJava/communityprocess/mrel/jsr221/index.html">"The Java Community Process(SM) Program - communityprocess - mrel"</a>. <i>jcp.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-4"><span class="mw-cite-backlink"><b><a href="#cite_ref-4">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/7/docs/technotes/guides/jdbc/jdbc_41.html">"JDBC 4.1"</a>. <i>docs.oracle.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-5"><span class="mw-cite-backlink"><b><a href="#cite_ref-5">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://jcp.org/aboutJava/communityprocess/mrel/jsr221/index2.html">"The Java Community Process(SM) Program - communityprocess - mrel"</a>. <i>jcp.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-6"><span class="mw-cite-backlink"><b><a href="#cite_ref-6">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/jdbc_42.html">"JDBC 4.2"</a>. <i>docs.oracle.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-7"><span class="mw-cite-backlink"><b><a href="#cite_ref-7">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://jcp.org/aboutJava/communityprocess/mrel/jsr221/index3.html">"The Java Community Process(SM) Program - communityprocess - mrel"</a>. <i>jcp.org</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-8"><span class="mw-cite-backlink"><b><a href="#cite_ref-8">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://docs.oracle.com/javase/9/docs/api/java/sql/package-summary.html">"java.sql (Java SE 9 &amp; JDK 9)"</a>. <i>docs.oracle.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-FOOTNOTEBai202274-9"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBai202274_9-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai202274_9-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai202274_9-2"><sup><i><b>c</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai202274_9-3"><sup><i><b>d</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBai2022">Bai 2022</a>, p.&nbsp;74.</span>
</li>
<li id="cite_note-FOOTNOTEBai2022122–124§4.2.3.5_More_About_the_Execution_Methods-10"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_More_About_the_Execution_Methods_10-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBai2022">Bai 2022</a>, pp.&nbsp;122–124, §4.2.3.5 More About the Execution Methods.</span>
</li>
<li id="cite_note-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture-11"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-1"><sup><i><b>b</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai202272–74§3.2_JDBC_Components_and_Architecture_11-2"><sup><i><b>c</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBai2022">Bai 2022</a>, pp.&nbsp;72–74, §3.2 JDBC Components and Architecture.</span>
</li>
<li id="cite_note-FOOTNOTEHorstmann2022§5.5.3_SQL_Escapes-12"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEHorstmann2022§5.5.3_SQL_Escapes_12-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFHorstmann2022">Horstmann 2022</a>, §5.5.3 SQL Escapes.</span>
</li>
<li id="cite_note-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture-13"><span class="mw-cite-backlink">^ <a href="#cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture_13-0"><sup><i><b>a</b></i></sup></a> <a href="#cite_ref-FOOTNOTEBai2022122–124§4.2.3.5_JDBC_Components_and_Architecture_13-1"><sup><i><b>b</b></i></sup></a></span> <span class="reference-text"><a href="#CITEREFBai2022">Bai 2022</a>, pp.&nbsp;122–124, §4.2.3.5 JDBC Components and Architecture.</span>
</li>
<li id="cite_note-FOOTNOTEBai202283§3.5.1_JDBC_DataSource-14"><span class="mw-cite-backlink"><b><a href="#cite_ref-FOOTNOTEBai202283§3.5.1_JDBC_DataSource_14-0">^</a></b></span> <span class="reference-text"><a href="#CITEREFBai2022">Bai 2022</a>, p.&nbsp;83, §3.5.1 JDBC DataSource.</span>
</li>
<li id="cite_note-15"><span class="mw-cite-backlink"><b><a href="#cite_ref-15">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc/">"Java JDBC API"</a>. <i>docs.oracle.com</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-16"><span class="mw-cite-backlink"><b><a href="#cite_ref-16">^</a></b></span> <span class="reference-text">
<cite id="CITEREFGreenwaldStackowiakStern1999" class="citation book cs1">Greenwald, Rick; Stackowiak, Robert; Stern, Jonathan (1999). <a rel="nofollow" class="external text" href="https://books.google.com/books?id=CTebAgAAQBAJ"><i>Oracle Essentials: Oracle Database 10g</i></a>. Essentials Series (3&nbsp;ed.). Sebastopol, California: O'Reilly Media, Inc. (published 2004). p.&nbsp;318. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>9780596005856</bdi><span class="reference-accessdate">. Retrieved <span class="nowrap">2016-11-03</span></span>. <q><i>The in-database JDBC driver (JDBC KPRB)</i>[:] Java code uses the JDBC KPRB (Kernel Program Bundled) version to access SQL on the same server.</q></cite></span>
</li>
<li id="cite_note-17"><span class="mw-cite-backlink"><b><a href="#cite_ref-17">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.cdata.com/jdbc/">"JDBC Drivers - CData Software"</a>. <i>CData Software</i><span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-18"><span class="mw-cite-backlink"><b><a href="#cite_ref-18">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="https://web.archive.org/web/20151222115409/http://www.rssbus.com/jdbc/">"JDBC Drivers - CData Software"</a>. <i>CData Software</i>. Archived from <a rel="nofollow" class="external text" href="http://www.rssbus.com/jdbc/">the original</a> on 22 December 2015<span class="reference-accessdate">. Retrieved <span class="nowrap">22 March</span> 2018</span>.</cite></span>
</li>
<li id="cite_note-datadirect-19"><span class="mw-cite-backlink"><b><a href="#cite_ref-datadirect_19-0">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://www.datadirect.com/products/features/data-connectivity/type-5-jdbc/index.html">"New Type 5 JDBC Driver&nbsp;— DataDirect Connect"</a>.</cite></span>
</li>
<li id="cite_note-20"><span class="mw-cite-backlink"><b><a href="#cite_ref-20">^</a></b></span> <span class="reference-text"><cite class="citation web cs1"><a rel="nofollow" class="external text" href="http://iprodeveloper.com/rpg-programming/access-external-databases-rpg-jdbcr4">"Access External Databases from RPG with JDBCR4 Meat of the Matter"</a>. 28 June 2012<span class="reference-accessdate">. Retrieved <span class="nowrap">12 April</span> 2016</span>.</cite></span>
</li>
<li id="cite_note-schemacrawler-21"><span class="mw-cite-backlink"><b><a href="#cite_ref-schemacrawler_21-0">^</a></b></span> <span class="reference-text"><cite id="CITEREFSualeh_Fatehi" class="citation web cs1">Sualeh Fatehi. <a rel="nofollow" class="external text" href="https://github.com/schemacrawler/SchemaCrawler">"SchemaCrawler"</a>. <i>GitHub</i>.</cite></span>
</li>
</ol></div></div>
<div class="mw-heading mw-heading2"><h2 id="References">References</h2></div>
<ul><li><cite id="CITEREFBai2022" class="citation book cs1">Bai, Ying (2022). <i>SQL Server Database Programming with Java</i>. Cham: <a href="Springer_International_Publishing" class="mw-redirect" title="Springer International Publishing">Springer International Publishing</a>. <a href="Doi_(identifier)" class="mw-redirect" title="Doi (identifier)">doi</a>:<a rel="nofollow" class="external text" href="https://doi.org/10.1007%2F978-3-031-06553-8">10.1007/978-3-031-06553-8</a>. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-3-030-92686-1</bdi>.</cite></li>
<li><cite id="CITEREFHorstmann2022" class="citation book cs1">Horstmann, Cay (April 15, 2022). <i>Core Java</i>. Oracle Press Java. <a href="ISBN_(identifier)" class="mw-redirect" title="ISBN (identifier)">ISBN</a>&nbsp;<bdi>978-0-13-787107-0</bdi>.</cite></li></ul>
<div class="mw-heading mw-heading2"><h2 id="External_links">External links</h2></div>
<style data-mw-deduplicate="TemplateStyles:r1290876196">
/* start https://en.wikipedia.org/ */


.mw-parser-output .side-box{margin:4px 0;box-sizing:border-box;border:1px solid #aaa;font-size:88%;line-height:1.25em;background-color:var(--background-color-interactive-subtle,#f8f9fa);display:flow-root}.mw-parser-output .infobox .side-box{font-size:100%}.mw-parser-output .side-box-abovebelow,.mw-parser-output .side-box-text{padding:0.25em 0.9em}.mw-parser-output .side-box-image{padding:2px 0 2px 0.9em;text-align:center}.mw-parser-output .side-box-imageright{padding:2px 0.9em 2px 0;text-align:center}@media(min-width:500px){.mw-parser-output .side-box-flex{display:flex;align-items:center}.mw-parser-output .side-box-text{flex:1;min-width:0}}@media(min-width:720px){.mw-parser-output .side-box{width:238px}.mw-parser-output .side-box-right{clear:right;float:right;margin-left:1em}.mw-parser-output .side-box-left{margin-right:1em}}


/* end https://en.wikipedia.org/ */
</style><style data-mw-deduplicate="TemplateStyles:r1237033735">
/* start https://en.wikipedia.org/ */


@media print{body.ns-0 .mw-parser-output .sistersitebox{display:none!important}}@media screen{html.skin-theme-clientpref-night .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}@media screen and (prefers-color-scheme:dark){html.skin-theme-clientpref-os .mw-parser-output .sistersitebox img[src*="Wiktionary-logo-en-v2.svg"]{background-color:white}}


/* end https://en.wikipedia.org/ */
</style><div class="side-box side-box-right sistersitebox"><style data-mw-deduplicate="TemplateStyles:r1126788409">
/* start https://en.wikipedia.org/ */


.mw-parser-output .plainlist ol,.mw-parser-output .plainlist ul{line-height:inherit;list-style:none;margin:0;padding:0}.mw-parser-output .plainlist ol li,.mw-parser-output .plainlist ul li{margin-bottom:0}


/* end https://en.wikipedia.org/ */
</style>
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikimedia Commons has media related to <span style="font-weight: bold; font-style: italic;"><a href="https://commons.wikimedia.org/wiki/Category:JDBC" class="extiw external" title="commons:Category:JDBC">JDBC</a></span>.</div></div>
</div>
<div class="side-box side-box-right sistersitebox">
<div class="side-box-flex">
<div class="side-box-image"><span class="noviewer" typeof="mw:File"></span></div>
<div class="side-box-text plainlist">Wikibooks has a book on the topic of: <i><b><a href="https://en.wikibooks.org/wiki/Java_Programming/Database_Programming" class="extiw external" title="wikibooks:Java Programming/Database Programming">Java Programming/Database Programming</a></b></i></div></div>
</div>
<ul><li><a rel="nofollow" class="external text" href="https://docs.oracle.com/javase/8/docs/technotes/guides/jdbc">JDBC API Guide</a></li>
<li><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/java/sql/package-summary.html">java.sql</a></code> API <a href="Javadoc" title="Javadoc">Javadoc</a> documentation</li>
<li><code><a rel="nofollow" class="external text" href="https://docs.oracle.com/en/java/javase/24/docs/api/java.sql/javax/sql/package-summary.html">javax.sql</a></code> API Javadoc documentation</li>
<li><a rel="nofollow" class="external text" href="https://web.archive.org/web/20160111210342/http://orbroker.org/">O/R Broker</a> Scala JDBC framework</li>
<li><a rel="nofollow" class="external text" href="http://www.hsqldb.org/doc/2.0/util-guide/sqltool-chapt.html">SqlTool</a> Open source, command-line, generic JDBC client utility. Works with any JDBC-supporting database.</li>
<li><a rel="nofollow" class="external text" href="http://codeoftheday.blogspot.com/2012/12/java-database-connectivity-jdbc-url.html">JDBC URL Strings and related information of All Databases.</a></li></ul></div><!--htdig_noindex--><div><div class="zim-footer">
This article is issued from <a class="external text" title="Last edited on 2025-07-31" href="https://en.wikipedia.org/wiki/?title=Java_Database_Connectivity&amp;oldid=1303561985">Wikipedia</a>. The text is available under <a class="external text" href="https://creativecommons.org/licenses/by-sa/4.0/deed.en">Creative Commons Attribution-Share Alike 4.0</a> unless otherwise noted. Additional terms may apply for the media files.
</div>
</div><!--/htdig_noindex--></div>
</div>
</main>
</div>
</div>
</div>

</body></html>